class UnusualAdd {
public:
/*    
    //循环法
    int addAB(int A, int B) {
        if(A == 0){
            return B;
        }
        int add = B;
        for(int i = 0; i < A; ++i){
            ++add;    //给 B 进行 A次++
        }
        return add;
    }
 */
    int addAB(int A, int B) {
       /* if(A == 0){
            return B;
        }
        return addAB(A ^ B, (A & B) << 1);  //超时
        */  
         while (B != 0) {
            int sum = A ^ B;  // 异或模拟加，按位与左移模拟进位
            int carry = (A & B) << 1;  //进位为1左移一位
            A = sum;
            B = carry;
        }
        return A;
    }
};
